<!DOCTYPE html>
<html lang="en">

<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
    <style>
        .heading td {
            background: #1D9FDF;
            color: white;
            text-align: center;
            border: none;
        }

        #heading {
            text-align: center;
        }


        table {
            border-collapse: collapse;
        }

        td {
            border: 1px solid black;
            height: 30px;
            width: 280px;
            text-align: center;
            font-weight: bold;
        }

        .noBorder td {
            border: none;
            background: lightgray;
        }

        table thead {
            background: gray;
        }

        .reporttable {
            border-collapse: collapse;
        }
    </style>


    <script>
        var json = "";
        var district = "";
        var checkOuLevel = function (ou) {
            $.ajax({
                async: false,
                type: "GET",
                url: "../api/organisationUnits/" + ou + ".json",
                success: function (data) {
                    json = data;

                }
            });
            return json;
        };

        var checkDataset = function (ou) {
            var count = 0;
            $.ajax({
                async: false,
                type: "GET",
                url: "../api/organisationUnits/" + ou + ".json",
                success: function (data) {
                    //     json = data;


                    for (var p = 0; p < data.dataSets.length; p++) {
                        if (data.dataSets[p].id === "PFHKrQJxO85") {
                            count = 1;
                        }
                    }
                }
            });
            if (count == 1) { return 1; }
            else { return 0; }
            //     return 0;
        };

        var getPeriodArray = function (pe, ouPe) {
            var array = "";
            pe = parseInt(pe);

            while (pe != 201700) {
                array = array + pe + ";";
                pe -= 1;
            }
            array = array + ouPe;
            return array;
        };
        var month;
        var getMonth = function (a) {
            if (a == "1" || a == "01") { month = "January" }
            if (a == "2" || a == "02") { month = "February" }
            if (a == "3" || a == "03") { month = "March" }
            if (a == "4" || a == "04") { month = "April" }
            if (a == "5" || a == "05") { month = "May" }
            if (a == "6" || a == "06") { month = "June" }
            if (a == "7" || a == "07") { month = "July" }
            if (a == "8" || a == "08") { month = "August" }
            if (a == "9" || a == "09") { month = "September" }
            if (a == "10") { month = "october" }
            if (a == "11") { month = "November" }
            if (a == "12") { month = "December" }
        };

        var getDistrict = function (ou) {
            $.ajax({
                async: false,
                type: "GET",
                url: "../api/organisationUnits/" + ou + ".json?fields=ancestors[id,name,level]",
                success: function (data) {
                    for (var i = 0; i < data.ancestors.length; i++) {
                        if (data.ancestors[i].level == 2) {
                            district = data.ancestors[i].name;
                        }
                    }

                }
            });
            return district;
        };

        $(document).ready(function () {
            var url = window.location.href;
            var pe1 = url.split("&")[1];
            var pe = pe1.split("=")[1];
            var monthCode = pe.substr(4, 6);
            getMonth(monthCode);
            var year = pe.substr(0, 4);
            var ou1 = url.split("&")[2];
            var ou = ou1.split("=")[1];
            var ouLeveldata = checkOuLevel(ou);
            var ouLevel = ouLeveldata.level;
            var index = 1;
            //var ouLeveldata5 = checkOuLevel(ou);
            //var ouPeriod = ouLeveldata5.openingDate;
            //var ouPe1 = ouPeriod.split('T')[0];
            //var ouPe2 = ouPe1.split('-');
            //var ouPe = ouPe2[0] + ouPe2[1];


                $("#export").click(function (e) {
                    e.preventDefault();

                    //getting data from our table
                    var data_type = 'data:application/vnd.ms-excel';
                    var table_div = document.getElementById('report_table');
                    var table_html = table_div.outerHTML.replace(/ /g, '%20');

                    var a = document.createElement('a');
                    a.href = data_type + ', ' + table_html;
                    a.download = 'EMP Report.xls';
                    a.click();
                });
           
            var periodArray = getPeriodArray(pe);

            var printData = function (ou, i) {


                var mtrow1 = "", mtrow2 = "", mtrow3 = "", mtrow4 = "", mtrow5 = "", mtrow6 = "", mtrow7 = "", mtrow8 = "", mtrow9 = "", mtrow10 = "", mtrow11 = "", mtrow12 = "", mtrow13 = "", mtrow14 = "", mtrow15 = "", mtrow16 = "";
                var ctrow1 = 0, ctrow2 = 0, ctrow3 = 0, ctrow4 = 0, ctrow5 = 0, ctrow6 = 0, ctrow7 = 0, ctrow8 = 0, ctrow9 = 0, ctrow10 = 0, ctrow11 = 0, ctrow12 = 0, ctrow13 = 0, ctrow14 = 0, ctrow15 = 0, ctrow16 = 0;
                var rtrow1 = "", rtrow2 = "", rtrow3 = "", rtrow4 = "", rtrow5 = "", rtrow6 = "", rtrow7 = "", rtrow8 = "", rtrow9 = "", rtrow10 = "", rtrow11 = "", rtrow12 = "", rtrow13 = "", rtrow14 = "", rtrow15 = "", rtrow16 = "";

                var msrow1 = "", msrow2 = "", msrow3 = "", msrow4 = "", msrow5 = "", msrow6 = "", msrow7 = "", msrow8 = "", msrow9 = "", msrow10 = "", msrow11 = "", msrow12 = "", msrow13 = "", msrow14 = "", msrow15 = "", msrow16 = "";
                var csrow1 = 0, csrow2 = 0, csrow3 = 0, csrow4 = 0, csrow5 = 0, csrow6 = 0, csrow7 = 0, csrow8 = 0, csrow9 = 0, csrow10 = 0, csrow11 = 0, csrow12 = 0, csrow13 = 0, csrow14 = 0, csrow15 = 0, csrow16 = 0;
                var rsrow1 = "", rsrow2 = "", rsrow3 = "", rsrow4 = "", rsrow5 = "", rsrow6 = "", rsrow7 = "", rsrow8 = "", rsrow9 = "", rsrow10 = "", rsrow11 = "", rsrow12 = "", rsrow13 = "", rsrow14 = "", rsrow15 = "", rsrow16 = "";

                $.ajax({
                    async: false,
                    type: "GET",
                    url: "../api/26/analytics.json?dimension=pe:" + pe + "&dimension=dx:N2TQYh2UuKi;RkX8I5a7MFK;m0rBXRl3plk;DDGqNt4Om9Q;aJydfz8A5hX;BuldqB0ZjQA;O0hupdHg2EK;JKN2BhumCFs;lSNdln9rT5B;UqME4pFAQi1;NBgZVw6S5dT;PqgpfyGbcDp;XW3Ibmwu2yH;AiFPv8kjFs2;Tn4LwgSL62v;lH2WGu5Sb9P;kgCohl9kPwR;fyUQxdYq9OR;MkFvO45G6g9;Ycb7xJN7FE4;f5rcYDmb7ON;iuMOCZhsq3h;ZAS9R1rjb1l;wnE5Aezjwf0;X9JFZAZ6mcc;GTpQtQDU1rf;fzCEKhNgnnL;mHmJ88KHFFZ;AkKVOt8gkFa;sTbRLuD0foP;gVRlIpAnxrC;U1V6aGL7a1n;IYQiHBOHPba;EeqVIpWnEJP;kuPtCl3r85d;Jzz6Z0eLz4o;d18lpYhlRVt;qLPPKaCGzw1;D6KmAG0Wrci;PIec6Si93u2;jKQGc1HhVnp;gUiAxYmEPnJ;BIwEYlovX9n;ygANfczOmYl;p9R1dsl0WBL;LIzUuu0kyD5;BvW5bw1O3AM;MrV9KmlSJ5K;YT8BseMPicW;WwzaxG18vTC;yMd3cHYYa0S;yT8RwOJBmZW;m0PVtqT574F;mjwxSjxZLus;khAqmOyuCYB;HGhAaYpkMVD;IGzAcRB0uMK;GjGh8Hp4ZLD;dEODUCnMMwc;XthSW10I7ID;w0ebrvCtQmt;uRYDKiPpwWO;TeiQU3FTWTP;zEGEXAjxGtI&filter=ou:" + ou + "&displayProperty=SHORTNAME&outputIdScheme=NAME",
                    success: function (data) {


                        for (var i = 0; i < data.rows.length; i++) {

                            //monthly technical

                            if (data.rows[i][0] == "EMP_Spoil disposal management_Preparation of spoil disposal management plan") {
                                mtrow1 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of cutting") {
                                mtrow2 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of filling") {
                                mtrow3 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of safely disposed spoil") {
                                mtrow4 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Location of spoil disposal site") {
                                mtrow5 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Number and volume of toe wall constructed") {
                                mtrow6 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Location") {
                                mtrow7 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Volume of aggregates/stones/other materials supplied") {
                                mtrow8 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Rehabilitation of site") {
                                mtrow9 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Location") {
                                mtrow10 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Type of measures taken") {
                                mtrow11 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Number and volume of structure") {
                                mtrow12 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Location") {
                                mtrow13 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Area") {
                                mtrow14 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Type of measures taken") {
                                mtrow15 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Amount spent") {
                                mtrow16 = parseInt(data.rows[i][2]);
                            }

                            //remarks technical

                            if (data.rows[i][0] == "EMP_Spoil disposal management_Preparation of spoil disposal management plan_Remark") {
                                rtrow1 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of cutting_Remark") {
                                rtrow2 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of filling_Remark") {
                                rtrow3 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of safely disposed spoil_Remark") {
                                rtrow4 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Location of spoil disposal site_Remark") {
                                rtrow5 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Spoil disposal management_Number and volume of toe wall constructed_Remark") {
                                rtrow6 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Location_Remark") {
                                rtrow7 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Volume of aggregates/stones/other materials supplied_Remark") {
                                rtrow8 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Quarry site management_Rehabilitation of site_Remark") {
                                rtrow9 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Location_Remark") {
                                rtrow10 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Type of measures taken_Remark") {
                                rtrow11 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Number and volume of structure_Remark") {
                                rtrow12 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Location_Remark") {
                                rtrow13 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Area_Remark") {
                                rtrow14 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Type of measures taken_Remark") {
                                rtrow15 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Bioengineering works_ Amount spent_Remark") {
                                rtrow16 = data.rows[i][2];
                            }

                            //monthly social

                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Name of forest") {
                                msrow1 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Exact tree loss at Field") {
                                msrow2 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Plantation carried out") {
                                msrow3 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Amount spent") {
                                msrow4 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Exact tree loss at Field") {
                                msrow5 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Plantation carried out") {
                                msrow6 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Amount spent") {
                                msrow7 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Plantation carried out") {
                                msrow8 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Location") {
                                msrow9 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Amount spent") {
                                msrow10 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location") {
                                msrow11 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location 2") {
                                msrow12 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Number") {
                                msrow13 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Location") {
                                msrow14 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Number of meeting held") {
                                msrow15 = parseInt(data.rows[i][2]);
                            }
                            if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Environmental monitoring done ") {
                                msrow16 = parseInt(data.rows[i][2]);
                            }

                            //remarks social

                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Name of forest_Remark") {
                                rsrow1 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Exact tree loss at Field_Remark") {
                                rsrow2 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Plantation carried out_Remark") {
                                rsrow3 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Amount spent_Remark") {
                                rsrow4 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Exact tree loss at Field_Remark") {
                                rsrow5 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Plantation carried out_Remark") {
                                rsrow6 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Amount spent_Remark") {
                                rsrow7 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Plantation carried out_Remark") {
                                rsrow8 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Location_Remark") {
                                rsrow9 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Road side plantation_Amount spent_Remark") {
                                rsrow10 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location_Remark") {
                                rsrow11 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location_Remark 2") {
                                rsrow12 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Number_Remark") {
                                rsrow13 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Location_Remark") {
                                rsrow14 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Number of meeting held_Remark") {
                                rsrow15 = data.rows[i][2];
                            }
                            if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Environmental monitoring done_Remark") {
                                rsrow16 = data.rows[i][2];
                            }
                        }
                        $.ajax({
                            async: false,
                            type: "GET",
                            url: "../api/26/analytics.json?dimension=pe:2015;2016;" + periodArray + "&dimension=dx:N2TQYh2UuKi;RkX8I5a7MFK;m0rBXRl3plk;DDGqNt4Om9Q;aJydfz8A5hX;BuldqB0ZjQA;O0hupdHg2EK;JKN2BhumCFs;lSNdln9rT5B;UqME4pFAQi1;NBgZVw6S5dT;PqgpfyGbcDp;XW3Ibmwu2yH;AiFPv8kjFs2;Tn4LwgSL62v;lH2WGu5Sb9P;kgCohl9kPwR;fyUQxdYq9OR;MkFvO45G6g9;Ycb7xJN7FE4;f5rcYDmb7ON;iuMOCZhsq3h;ZAS9R1rjb1l;wnE5Aezjwf0;X9JFZAZ6mcc;GTpQtQDU1rf;fzCEKhNgnnL;mHmJ88KHFFZ;AkKVOt8gkFa;sTbRLuD0foP;gVRlIpAnxrC;U1V6aGL7a1n;IYQiHBOHPba;EeqVIpWnEJP;kuPtCl3r85d;Jzz6Z0eLz4o;d18lpYhlRVt;qLPPKaCGzw1;D6KmAG0Wrci;PIec6Si93u2;jKQGc1HhVnp;gUiAxYmEPnJ;BIwEYlovX9n;ygANfczOmYl;p9R1dsl0WBL;LIzUuu0kyD5;BvW5bw1O3AM;MrV9KmlSJ5K;YT8BseMPicW;WwzaxG18vTC;yMd3cHYYa0S;yT8RwOJBmZW;m0PVtqT574F;mjwxSjxZLus;khAqmOyuCYB;HGhAaYpkMVD;IGzAcRB0uMK;GjGh8Hp4ZLD;dEODUCnMMwc;XthSW10I7ID;w0ebrvCtQmt;uRYDKiPpwWO;TeiQU3FTWTP;zEGEXAjxGtI&filter=ou:" + ou + "&displayProperty=SHORTNAME&outputIdScheme=NAME",
                            success: function (data) {
                                for (var i = 0; i < data.rows.length; i++) {

                                    //technical commulative

                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Preparation of spoil disposal management plan") {
                                        ctrow1 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of cutting") {
                                        ctrow2 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of filling") {
                                        ctrow3 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Volume of safely disposed spoil") {
                                        ctrow4 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Location of spoil disposal site") {
                                        ctrow5 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Spoil disposal management_Number and volume of toe wall constructed") {
                                        ctrow6 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Quarry site management_Location") {
                                        ctrow7 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Quarry site management_Volume of aggregates/stones/other materials supplied") {
                                        ctrow8 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Quarry site management_Rehabilitation of site") {
                                        ctrow9 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Location") {
                                        ctrow10 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Type of measures taken") {
                                        ctrow11 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Land slide and erosion control measures_ Number and volume of structure") {
                                        ctrow12 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Bioengineering works_ Location") {
                                        ctrow13 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Bioengineering works_ Area") {
                                        ctrow14 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Bioengineering works_ Type of measures taken") {
                                        ctrow15 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Bioengineering works_ Amount spent") {
                                        ctrow16 += parseInt(data.rows[i][2]);
                                    }
                                    //social commulative

                                    if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Name of forest") {
                                        csrow1 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Exact tree loss at Field") {
                                        csrow2 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Plantation carried out") {
                                        csrow3 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in forest area_Amount spent") {
                                        csrow4 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Exact tree loss at Field") {
                                        csrow5 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Plantation carried out") {
                                        csrow6 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensatory plantation in private land_ Amount spent") {
                                        csrow7 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Road side plantation_Plantation carried out") {
                                        csrow8 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Road side plantation_Location") {
                                        csrow9 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Road side plantation_Amount spent") {
                                        csrow10 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location") {
                                        csrow11 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Compensation/Rehabilitation of public infrastructure along road side_Name & Location 2") {
                                        csrow12 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Number") {
                                        csrow13 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Informative/safety/environmental awareness signboard erected_Location") {
                                        csrow14 += data.rows[i][2] + ",";
                                    }
                                    if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Number of meeting held") {
                                        csrow15 += parseInt(data.rows[i][2]);
                                    }
                                    if (data.rows[i][0] == "EMP_Meeting convened by safeguard desk_Environmental monitoring done ") {
                                        csrow16 += parseInt(data.rows[i][2]);
                                    }
                                }
                            }


                        });
                    }
                });


                var row = "";
                var getName = checkOuLevel(ou);
                var ouname = getName.name;
                var districtt = getDistrict(ou);
                var table = "<table class='reporttable_" + i + "' border='1'></table>";
                $(".tableattach").append(table);
                //name of ou
                var row = "<tr  bgcolor='lightgray'><td colspan= '1'>District :</td><td colspan='1'>" + districtt + "</td><td colspan='1'>Sub-project :</td><td colspan='1'>" + ouname + "</td><td colspan='1'>Period :</td><td colspan='1'>" + month + " " + year + "</td></tr>";

                //heading
                row = row + "<tr><td>Value</td><td>Description</td><td>Indicator</td><td>Monthly</td><td>Cumulative</td><td>Remarks</td></tr>";

                // first row : techincal
                row = row + "<tr><td rowspan='16'>Technical</td><td rowspan='6'>Spoil disposal management</td><td>Preparation of spoil disposal management plan (Y/N)</td><td>" + mtrow1 + "</td><td>" + ctrow1 + "</td><td>" + rtrow1 + "</td></tr>";
                row = row + "<tr><td>Volume of cutting (m3)</td><td>" + mtrow2 + "</td><td>" + ctrow2 + "</td><td>" + rtrow2 + "</td></tr>";
                row = row + "<tr><td>Volume of filling (m3)</td><td>" + mtrow3 + "</td><td>" + ctrow3 + "</td><td>" + rtrow3 + "</td></tr>";
                row = row + "<tr><td>Volume of safely disposed spoil (m3)</td><td>" + mtrow4 + "</td><td>" + ctrow4 + "</td><td>" + rtrow4 + "</td></tr>";
                row = row + "<tr><td>Location of spoil disposal site (Ch or address)</td><td>" + mtrow5 + "</td><td>" + ctrow5 + "</td><td>" + rtrow5 + "</td></tr>";
                row = row + "<tr><td>Number and volume (m3) of toe wall constructed</td><td>" + mtrow6 + "</td><td>" + ctrow6 + "</td><td>" + rtrow6 + "</td></tr>";
                row = row + "<tr><td rowspan='3'>Quarry site management</td><td>Location</td><td>" + mtrow7 + "</td><td>" + ctrow7 + "</td><td>" + rtrow7 + "</td></tr>";
                row = row + "<tr><td>Volume of aggregates/stones/other materials supplied (m3 )</td><td>" + mtrow8 + "</td><td>" + ctrow8 + "</td><td>" + rtrow8 + "</td></tr>";
                row = row + "<tr><td>Rehabilitation of site (Y/N)</td><td>" + mtrow9 + "</td><td>" + ctrow9 + "</td><td>" + rtrow9 + "</td></tr>";
                row = row + "<tr><td rowspan='3'>Land slide and erosion control measures</td><td>Location (Ch)</td><td>" + mtrow10 + "</td><td>" + ctrow10 + "</td><td>" + rtrow10 + "</td></tr>";
                row = row + "<tr><td>Type of measures taken</td><td>" + mtrow11 + "</td><td>" + ctrow11 + "</td><td>" + rtrow11 + "</td></tr>";
                row = row + "<tr><td>Number and volume of structure (m3)</td><td>" + mtrow12 + "</td><td>" + ctrow12 + "</td><td>" + rtrow12 + "</td></tr>";
                row = row + "<tr><td rowspan='4'>Bioengineering works</td><td>Location (Ch)</td><td>" + mtrow13 + "</td><td>" + ctrow13 + "</td><td>" + rtrow13 + "</td></tr>";
                row = row + "<tr><td>Area (Rm/m2)</td><td>" + mtrow14 + "</td><td>" + ctrow14 + "</td><td>" + rtrow14 + "</td></tr>";
                row = row + "<tr><td>Type of measures taken</td><td>" + mtrow15 + "</td><td>" + ctrow15 + "</td><td>" + rtrow15 + "</td></tr>";
                row = row + "<tr><td>Amount spent (NRs.)</td><td>" + mtrow16 + "</td><td>" + ctrow16 + "</td><td>" + rtrow16 + "</td></tr>";

                // second row Social
                row = row + "<tr><td rowspan='16'>Social</td><td rowspan='4'>Compensatory plantation in forest area</td><td>Name of forest</td><td>" + msrow1 + "</td><td>" + csrow1 + "</td><td>" + rsrow1 + "</td></tr>";
                row = row + "<tr><td>Exact tree loss at Field (No.)</td><td>" + msrow2 + "</td><td>" + csrow2 + "</td><td>" + rsrow2 + "</td></tr>";
                row = row + "<tr><td>Plantation carried out (No.)</td><td>" + msrow3 + "</td><td>" + csrow3 + "</td><td>" + rsrow3 + "</td></tr>";
                row = row + "<tr><td>Amount spent (NRs.)</td><td>" + msrow4 + "</td><td>" + csrow4 + "</td><td>" + rsrow4 + "</td></tr>";
                row = row + "<tr><td rowspan='3'>Compensatory plantation in private land</td><td>Exact tree loss at Field (No.)</td><td>" + msrow5 + "</td><td>" + csrow4 + "</td><td>" + rsrow5 + "</td></tr>";
                row = row + "<tr><td>Plantation carried out (No.)</td><td>" + msrow6 + "</td><td>" + csrow6 + "</td><td>" + rsrow6 + "</td></tr>";
                row = row + "<tr><td>Amount spent (NRs.)</td><td>" + msrow7 + "</td><td>" + csrow7 + "</td><td>" + rsrow7 + "</td></tr>";
                row = row + "<tr><td rowspan='3'>Road side plantation</td><td>Plantation carried out (No.)</td><td>" + msrow8 + "</td><td>" + csrow8 + "</td><td>" + rsrow8 + "</td></tr>";
                row = row + "<tr><td>Location (Ch or address)</td><td>" + msrow9 + "</td><td>" + csrow9 + "</td><td>" + rsrow9 + "</td></tr>";
                row = row + "<tr><td>Amount spent (NRs.)</td><td>" + msrow10 + "</td><td>" + csrow10 + "</td><td>" + rsrow10 + "</td></tr>";
                row = row + "<tr><td rowspan='2'>Compensation/Rehabilitation of public infrastructure along road side</td><td>1.     Name & Location</td><td>" + msrow11 + "</td><td>" + csrow11 + "</td><td>" + rsrow11 + "</td></tr>";
                row = row + "<tr><td>2.     Name & Location</td><td>" + msrow12 + "</td><td>" + csrow12 + "</td><td>" + rsrow12 + "</td></tr>";
                row = row + "<tr><td rowspan='2'>Informative/safety/environmental awareness signboard erected</td><td>Number</td><td>" + msrow13 + "</td><td>" + csrow13 + "</td><td>" + rsrow13 + "</td></tr>";
                row = row + "<tr><td>Location</td><td>" + msrow14 + "</td><td>" + csrow14 + "</td><td>" + rsrow14 + "</td></tr>";
                row = row + "<tr><td rowspan='2'>Meeting convened by safeguard desk</td><td>Number of meeting held</td><td>" + msrow15 + "</td><td>" + csrow15 + "</td><td>" + rsrow15 + "</td></tr>";
                row = row + "<tr><td>Environmental monitoring done</td><td>" + msrow16 + "</td><td>" + csrow16 + "</td><td>" + rsrow16 + "</td></tr>";
                $(".reporttable_" + i).append(row);
            };



            if (ouLevel == 1) {
                for (var p = 0; p < ouLeveldata.children.length; p++) {
                    var tempOu = ouLeveldata.children[p].id;
                    var tempOuData = checkOuLevel(tempOu);
                    if (tempOuData.children.length !== 0) {
                        for (var l = 0; l < tempOuData.children.length; l++) {
                            var tempOu2 = tempOuData.children[l].id;
                            //   var tempOuData2 = checkOuLevel(tempOu2);
                            var returnValue = checkDataset(tempOu2);
                            if (returnValue == 1) {
                                printData(tempOu2, index);
                                index++;
                            }
                        }
                    }
                }
            }
            else if (ouLevel == 2) {
                for (var p = 0; p < ouLeveldata.children.length; p++) {
                    var tempOu = ouLeveldata.children[p].id;
                    var returnValue = checkDataset(tempOu);
                    if (returnValue == 1) {
                        printData(tempOu, index);
                        index++;
                    }
                }
            }
            else if (ouLevel == 3) {
                printData(ou, 1);
            }
            else {
                alert("Wrong selection");
                window.history.back();;
            }


        });
    </script>
</head>

<body>
    <div id="body">
        <center><button id="export">Export to Excel</button></center>
        <br>
        <table class="table table-bordered" width="100%">
            <thead>
                <tr class="heading">
                    <td colspan="1" rowspan="3"><img src="../dhis-web-commons/security/DRILP_Logo.jpg" width="90%" height="400%"></td>
                    <td colspan="4" rowspan="1">
                        <p style="font-size:16px;">Earthquake Emergency Assistance Project (EEAP)</p>
                    </td>
                    <td colspan="1" rowspan="3"></td>
                </tr>
                <tr class="heading">
                    <td colspan="4" rowspan="1">
                        <p style="font-size:20px;">Rehabilitation and Reconstruction of District Roads</p>
                    </td>
                </tr>
                <tr class="heading">
                    <td colspan="4" rowspan="1">
                        <p style="font-size:16px;">EMP Report</p>
                    </td>
                </tr>
            </thead>
        </table>
        <table id="report_table" class="tableattach"></table>
        <br>
    </div>
</body>

</html>